﻿using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace 纸片人.win2dEffectControl.DataClass
{
    public class ArithmeticCompositeEffectData : EffectTwoSourceData
    {
        #region 属性
      

        private bool _clampOutput = false;
        private float _multiplyAmount=1;
        private float _offset;
        private Vector2 _sourceAmount;

        public bool ClampOutput { get => _clampOutput; set { _clampOutput = value; OnPropertyChanged(); SetIsChanges(); } }
        public float MultiplyAmount { get => _multiplyAmount; set { _multiplyAmount = value; OnPropertyChanged(); SetIsChanges(); } }
        public float Offset
        {
            get { return _offset; }
            set { _offset = value; OnPropertyChanged();SetIsChanges(); }
        }
        public Vector2 SourceAmount { get => _sourceAmount; set { _sourceAmount = value; OnPropertyChanged(); SetIsChanges(); } }

        #endregion


        public override ICanvasImage GetEffect(CanvasDevice device, bool compression)
        {
            var source = GetSourceEffect(device, compression);
            if (source == null)
            {
                return null;
            }

            var twoSource = GetSourceTwoEffect(device, compression);

            ArithmeticCompositeEffect effect = new ArithmeticCompositeEffect()
            {
                ClampOutput = ClampOutput,
                MultiplyAmount = MultiplyAmount,
                Offset = Offset,
                Source1Amount = SourceAmount.X,
                Source2Amount = SourceAmount.Y,
                Source1 = source,
                Source2 = twoSource,
            };

            return effect;
        }
    }
}
